package com.web.new12306.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.web.new12306.pojo.User;
import com.web.new12306.service.UserService;
import com.web.new12306.service.impl.UserServiceImpl;

/**
 * @author 蔡艳
 * 
 */

public class showPersonServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		//PrintWriter out=response.getWriter();
		
		UserService userService=new UserServiceImpl();
		HttpSession session = request.getSession();
		User user=new User();
		String name=(String) session.getAttribute("username");
		user.setUsername(name);
		User users = userService.showPerson(user);
        request.setAttribute("user", users);
        //System.out.println(users.getId());
        request.getRequestDispatcher("/updatePerson.jsp").forward(request, response);

	}

}
